﻿using System;
using System.Collections.Generic; 
using System.Text;
using ATSIDAL;
using ATSModel;
using System.Data.SqlClient;
using System.Data;

namespace ATSDAL
{

    public class PIMTestItem : BaseRepository<PIMTestItemInfo>, IPIMTestItem
   {
       private const string PARM_TESTITEM_PRODUCTSN = "@ProductSN";
       private const string PARM_TESTITEM_TESTTIME = "@RecordTime";

       public IList<PIMTestItemInfo> LoadEntities()
       {
           return null;
       }

       public PIMTestItemInfo LoadEntity<T1>(T1 Id)
       {
           return null;
       }

       public IList<PIMTestItemInfo> GetTestItems(string productSN, DateTime testTime)
       { 
           SqlParameter[] testItemParms = GetSNTParameters(); 
           testItemParms[0].Value = productSN;
           testItemParms[1].Value = testTime;
           return ExcuteSqlToGetEntities("PIMTestItem_select_SNDT", testItemParms);
       }

       #region 参数部分
       private static SqlParameter[] GetSNTParameters()
       {
           SqlParameter[] parms = null;
           parms = new SqlParameter[]
                {
					new SqlParameter(PARM_TESTITEM_PRODUCTSN, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_TESTITEM_TESTTIME, SqlDbType.DateTime, 8)                
                };
           return parms;
       }
       #endregion

       #region 重写基类部分
       //-------------------------------------重写超类基础操作---------------------------------------------------------

       public override PIMTestItemInfo GetEntityRecord(SqlDataReader rdr)
       {
           PIMTestItemInfo pro = new PIMTestItemInfo
           { 
               id = rdr.GetValue(0).ToString(), 
               ProductSN = rdr.GetValue(1).ToString(),
               PIMRecordTime = rdr.GetDateTime(2),
               PIMFreq = rdr.GetValue(3).ToString(),
               PIMName = rdr.GetValue(4).ToString(),
               PIMValue =Convert.ToDecimal(rdr.GetValue(5).ToString()), 
               PIMPass = rdr.GetValue(6).ToString(),
               PIMAngle = rdr.GetValue(7).ToString()
           };
           return pro;
       }
       #endregion
   }
}
